package com.roger.myHome.test;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class Main {

    public static void main(String[] args) {
        User user = User.builder()
                .age(30)
                .email("john.doe@example.com")
                .address("123 Main St")
                .id(10)
                .build();
        User user1 = User.builder()
                .age(30)
                .name("张三")
                .email("john.doe@example.com")
                .address("123 Main St")
                .id(20)
                .build();
        User user2 = User.builder()
                .age(30)
                .name("李四")
                .email("john.doe@example.com")
                .address("123 Main St")
                .id(15)
                .build();
        List<User> list = new ArrayList<>();
        list.add(user);
        list.add(user1);
        list.add(user2);

        Collections.sort(list, new Comparator<User>() {
            @Override
            public int compare(User p1, User p2) {
                return Integer.compare(p1.getId(), p2.getId());
            }
        });

        System.out.println(list);

    }
}
